home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5336 < prev    next >
Encoding:
Text File  |  1996-08-05  |  944 b   |  37 lines

  1. Path: news.telepac.pt!usenet
  2. From: jcarlosr@mail.telepac.pt (J.Carlos)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie Q: Is there a Static pointer?
  5. Date: Sat, 03 Feb 1996 22:44:36 GMT
  6. Organization: telepac
  7. Message-ID: <4f0s5h$qbq@vivaldi.telepac.pt>
  8. References: <1996Jan27.223516.19031@freenet.victoria.bc.ca>
  9. NNTP-Posting-Host: alv1_p8.telepac.pt
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. ua187@freenet.Victoria.BC.CA (Alex Walker) wrote:
  13.  
  14.  
  15.  
  16. >    I'm learning C++ and at the moment making a doubly linked-list.
  17. >    I'd like to have a pointer to an object of which there is only 1
  18. >    copy and all memeber of the class (each node in the list) can use it.   
  19. >    This sounds like a static pointer, but does such an animal exists??.
  20.  
  21. Yes the animal exists, but don't forget to inicialize it, like this :
  22.  
  23. class SOMECLASS
  24.     {
  25.     static int x;
  26.  public:
  27.     SOMECLASS();
  28.     SOMECLASS();
  29.     };
  30.  
  31. int SOMECLASS::x = 0;
  32.  
  33. Hope this helps, J.Carlos
  34. jcarlosr@mail.telepac.pt
  35.  
  36.  
  37.